<?php 
    $entities = pc_variable("entities");
    $references = pc_variable("references");
    $typeName = pc_variable("typeName");
    $type = pc_config("type." . $typeName);
    $typeConfig = pc_config("cm.type." . $type->getFullName());
?>
<h2><?php pc_echo(pc_variable("title")); ?></h2>
<form action="./dispatcher.php" method="post">
    <fieldset>
        <?php foreach($entities as $entity) { ?>
        	<input type="hidden" name="ids[]" value="<?php pc_echo($entity->getId()); ?>"/>
        <?php } ?>
        <ul class="errors">
            <li><?php pc_echo(pc_message("deleteEntity.dependenciesExist", array(pc_message("namespace." . $typeName . ".plural")))); ?></li>
        </ul>
        <ul>
        <?php foreach($entities as $entity) { ?>
        	<li class="type-<?php pc_echo(Pageley_Util_String::splitCamelCase($type->getName(), "-")); ?>"><?php pc_echo($entity->get($typeConfig->getPrimaryPropertyName())); ?></li>
        <?php } ?>
        </ul>
        <p><?php pc_echo(pc_message("deleteEntity.dependencies", array(pc_message("namespace." . $typeName . ".plural")))); ?></p>
        <ul>
        <?php foreach($references as $reference) { 
            $t = $reference->getType();
            $tc = pc_config("cm.type." . $t->getFullName()); ?>
            <li class="type-<?php pc_echo(Pageley_Util_String::splitCamelCase($t->getName(), "-")); ?>">
                <?php pc_echo(pc_message("namespace." . $t->getFullName())); ?>
                <a href="<?php pc_echo(pc_link("Find", array("typeName" => $t->getFullName(), "id" => $reference->getId()))); ?>">
                     <?php pc_echo($reference->get($tc->getPrimaryPropertyName())); ?>
                </a>
            </li>
        <?php } ?>
        </ul>
    </fieldset>
    <fieldset class="buttons">
        <a href="<?php pc_echo(pc_link("Query", array("typeName" => $type->getFullName()))); ?>" class="cancel"/><?php pc_echo(pc_message("showEntity.cancel")); ?></a>
    </fieldset>
</form>
